package zengqiang.day04

/**
 * 密封类：超强的枚举
 * 密封类封装的是类型，表示类型是确定的
 */
fun main(args: Array<String>) {
    val f1=F.F1()
    println(siRight(f1))//true
    println(siRight(F5())) //false
}
fun siRight(f:F):Boolean{
    return when (f) {
        is F.F1->true
        is F.F2->true
        is F.F3->true
        is F.F4->true
        else->false
    }
}

/**'
 *sealed修饰的类，叫做密封类
 */
sealed class F{
    class F1:F()
    class F2:F()
    class F3:F()
    class F4:F()
}
class F5:F()